package com.zhoukx.factory.factorymethod.pizzastore.order;




import com.zhoukx.factory.factorymethod.pizzastore.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @ClassName OrderPizza
 * @Description: 订购披萨
 * @Author zhoukx
 * @Date 2020/8/6
 **/
public abstract class OrderPizza {

    // 定义一个抽象方法，createPizza，让工厂子类自己实现
    abstract Pizza createPizza(String orderType);

    public OrderPizza() {
        Pizza pizza = null;
        String orderType;// 订购披萨类型
        do {
            orderType = gettype();
            pizza = createPizza(orderType);
            // 输出披萨的 的制作过程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        } while (true);
    }


    // 写一个方法 动态获取客户希望订购的披萨种类
    private String gettype() {
        try {
            BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza type:");
            String str = strin.readLine();
            return str;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
